inherited fmRequestAnswers: TfmRequestAnswers
  Left = 396
  Top = 277
  Width = 804
  Height = 445
  Caption = 'fmRequestAnswers'
  Constraints.MinHeight = 445
  Constraints.MinWidth = 804
  OnShow = FormShow
  PixelsPerInch = 96
  TextHeight = 13
  inherited sbBottom: TStatusBar
    Top = 380
    Width = 788
  end
  inherited Panel1: TPanel
    Width = 788
    Visible = False
    inherited BitBtn1: TBitBtn
      Left = 626
    end
    inherited BitBtn2: TBitBtn
      Left = 714
    end
  end
  object dbgRR: TcxGrid [2]
    Left = 0
    Top = 73
    Width = 788
    Height = 307
    Align = alClient
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -13
    Font.Name = 'Tahoma'
    Font.Style = []
    ParentFont = False
    TabOrder = 2
    LookAndFeel.Kind = lfStandard
    LookAndFeel.SkinName = 'Office2007Black'
    object tvRR: TcxGridDBTableView
      NavigatorButtons.ConfirmDelete = False
      NavigatorButtons.PriorPage.Visible = True
      NavigatorButtons.Next.Visible = True
      NavigatorButtons.Insert.Visible = True
      NavigatorButtons.Append.Visible = False
      NavigatorButtons.Edit.Visible = False
      NavigatorButtons.Post.Visible = True
      NavigatorButtons.Cancel.Visible = False
      NavigatorButtons.Refresh.Visible = False
      NavigatorButtons.SaveBookmark.Visible = False
      NavigatorButtons.GotoBookmark.Visible = False
      NavigatorButtons.Filter.Visible = False
      FilterBox.Position = fpTop
      OnCellDblClick = tvRRCellDblClick
      DataController.DataSource = dlgDS
      DataController.Summary.DefaultGroupSummaryItems = <>
      DataController.Summary.FooterSummaryItems = <
        item
          Kind = skCount
          FieldName = 'RRID'
          Column = tvRRRRID
        end>
      DataController.Summary.SummaryGroups = <>
      Filtering.ColumnFilteredItemsList = True
      OptionsBehavior.CellHints = True
      OptionsBehavior.IncSearch = True
      OptionsCustomize.ColumnFiltering = False
      OptionsData.CancelOnExit = False
      OptionsData.Editing = False
      OptionsView.CellEndEllipsis = True
      OptionsView.NoDataToDisplayInfoText = '<'#1053#1077#1090' '#1076#1072#1085#1085#1099#1093'>'
      OptionsView.CellAutoHeight = True
      OptionsView.CellTextMaxLineCount = 1
      OptionsView.ColumnAutoWidth = True
      OptionsView.Footer = True
      OptionsView.HeaderEndEllipsis = True
      OptionsView.Indicator = True
      Preview.Visible = True
      Styles.Header = DMInv.cxSiniyText
      object tvRRRRID: TcxGridDBColumn
        Caption = #8470' '#1087'/'#1087
        DataBinding.FieldName = 'RRID'
        Width = 20
      end
      object tvRRRRTIMEENTER: TcxGridDBColumn
        Caption = #1044#1072#1090#1072
        DataBinding.FieldName = 'RRTIMEENTER'
        Width = 20
      end
      object tvRRTYPE_REQUEST: TcxGridDBColumn
        Caption = #1058#1080#1087
        DataBinding.FieldName = 'TYPE_REQUEST'
        Width = 20
      end
      object tvRRSCID: TcxGridDBColumn
        Caption = #8470' '#1044#1057
        DataBinding.FieldName = 'SCID'
        Width = 20
      end
      object tvRRSTNAME: TcxGridDBColumn
        Caption = #1059#1089#1083#1091#1075#1072
        DataBinding.FieldName = 'STNAME'
        Width = 20
      end
      object tvRRFIO_POLUCH: TcxGridDBColumn
        Caption = #1055#1086#1083#1091#1095#1072#1090#1077#1083#1100' '#1091#1089#1083#1091#1075
        DataBinding.FieldName = 'FIO_POLUCH'
        Width = 44
      end
      object tvRRPODR: TcxGridDBColumn
        Caption = #1054#1089#1085'. '#1087#1086#1076#1088#1072#1079#1076'.'
        DataBinding.FieldName = 'PODR'
        Width = 35
      end
      object tvRRFIO_DL: TcxGridDBColumn
        Caption = #1055#1086#1076#1087#1080#1089#1072#1083
        DataBinding.FieldName = 'FIO_DL'
        Width = 25
      end
      object tvRRRRNOTE: TcxGridDBColumn
        Caption = #1050#1086#1084#1084#1077#1085#1090#1072#1088#1080#1081
        DataBinding.FieldName = 'RRNOTE'
        Width = 32
      end
      object tvRRAUTOR: TcxGridDBColumn
        Caption = #1040#1074#1090#1086#1088
        DataBinding.FieldName = 'AUTOR'
        Width = 20
      end
      object tvRRREDAKTOR: TcxGridDBColumn
        Caption = #1056#1077#1076#1072#1082#1090#1086#1088
        DataBinding.FieldName = 'REDAKTOR'
        Width = 23
      end
      object tvRRRRTIMEEDIT: TcxGridDBColumn
        Caption = #1044#1072#1090#1072' '#1088#1077#1076#1072#1082#1090#1080#1088'.'
        DataBinding.FieldName = 'RRTIMEEDIT'
        Width = 40
      end
      object tvRRRRMANAGERNOTE: TcxGridDBColumn
        Caption = #1050#1086#1084#1084#1077#1085#1090'. '#1084#1077#1085#1077#1076#1078#1077#1088#1072
        DataBinding.FieldName = 'RRMANAGERNOTE'
        Width = 57
      end
      object tvRRRRMANAGER: TcxGridDBColumn
        Caption = #1052#1077#1085#1077#1076#1078#1077#1088
        DataBinding.FieldName = 'RRMANAGER'
        Width = 34
      end
      object tvRRRRDIREKTORNOTE: TcxGridDBColumn
        Caption = #1050#1086#1084#1084#1077#1085#1090'. '#1076#1080#1088#1077#1082#1090#1086#1088#1072
        DataBinding.FieldName = 'RRDIREKTORNOTE'
        Width = 68
      end
      object tvRRRRDIREKTOROK: TcxGridDBColumn
        Caption = #1040#1074#1090#1086#1088#1080#1079#1072#1094#1080#1103' '#1076#1080#1088'.'
        DataBinding.FieldName = 'RRDIREKTOROK'
        PropertiesClassName = 'TcxCheckBoxProperties'
        Properties.NullStyle = nssUnchecked
        Properties.ValueChecked = 1
        Properties.ValueUnchecked = 0
        Width = 70
      end
      object tvRRRRCLIENTANSWER: TcxGridDBColumn
        Caption = #1054#1090#1074#1077#1090' '#1076#1083#1103' '#1076#1086#1074#1077#1088'. '#1083#1080#1094#1072
        DataBinding.FieldName = 'RRCLIENTANSWER'
        Width = 124
      end
    end
    object cxGridLevel2: TcxGridLevel
      GridView = tvRR
    end
  end
  object Panel2: TPanel [3]
    Left = 0
    Top = 45
    Width = 788
    Height = 28
    Align = alTop
    BevelOuter = bvNone
    TabOrder = 3
    object eDate: TcxButtonEdit
      Tag = 950
      Left = 38
      Top = 2
      ParentFont = False
      Properties.Buttons = <
        item
          Glyph.Data = {
            F6000000424DF600000000000000760000002800000010000000100000000100
            0400000000008000000000000000000000001000000000000000000000000000
            8000008000000080800080000000800080008080000080808000C0C0C0000000
            FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00FFFFFFFFFFFF
            FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
            FFFFFFFFFFF0FFFFFFFFFFFFFF000FFFFFFFFFFFF00000FFFFFFFFFF0000000F
            FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
            FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF}
        end>
      Properties.MaxLength = 0
      Properties.ReadOnly = True
      Properties.OnButtonClick = eDatePropertiesButtonClick
      Properties.OnChange = eDatePropertiesChange
      Style.Font.Charset = DEFAULT_CHARSET
      Style.Font.Color = clWindowText
      Style.Font.Height = -13
      Style.Font.Name = 'Tahoma'
      Style.Font.Style = [fsBold]
      Style.LookAndFeel.SkinName = ''
      Style.Shadow = False
      Style.IsFontAssigned = True
      StyleDisabled.LookAndFeel.SkinName = ''
      StyleFocused.LookAndFeel.SkinName = ''
      StyleHot.LookAndFeel.SkinName = ''
      TabOrder = 0
      Width = 217
    end
    object cxLabel1: TcxLabel
      Left = 8
      Top = 4
      Caption = #1044#1072#1090#1072
    end
    object cxLabel2: TcxLabel
      Left = 259
      Top = 4
      Caption = #1058#1080#1087' '#1079#1072#1103#1074#1083#1077#1085#1080#1103
    end
    object dxLookupTreeView1: TdxLookupTreeView
      Left = 341
      Top = 2
      Width = 259
      Height = 24
      CanSelectParents = True
      Font.Charset = DEFAULT_CHARSET
      Font.Color = clWindowText
      Font.Height = -13
      Font.Name = 'Tahoma'
      Font.Style = []
      ParentColor = False
      ParentFont = False
      TabOrder = 3
      TabStop = True
      TreeViewColor = clWindow
      TreeViewCursor = crDefault
      TreeViewFont.Charset = DEFAULT_CHARSET
      TreeViewFont.Color = clWindowText
      TreeViewFont.Height = -11
      TreeViewFont.Name = 'MS Sans Serif'
      TreeViewFont.Style = []
      TreeViewIndent = 19
      TreeViewReadOnly = False
      TreeViewShowButtons = True
      TreeViewShowHint = False
      TreeViewShowLines = True
      TreeViewShowRoot = True
      TreeViewSortType = stNone
      OnCloseUp = dxLookupTreeView1CloseUp
      DividedChar = '.'
      ListSource = dsSD
      KeyField = 'SDID'
      ListField = 'SDNAME'
      Options = [trDBCanDelete, trDBConfirmDelete, trCanDBNavigate, trSmartRecordCopy, trCheckHasChildren]
      ParentField = 'SDPARID'
      RootValue = Null
      TextStyle = tvtsShort
      Alignment = taLeftJustify
    end
    object cbIsOk: TcxCheckBox
      Left = 607
      Top = 3
      Caption = #1055#1086#1082#1072#1079#1072#1090#1100' '#1072#1074#1090#1086#1088#1080#1079#1086#1074#1072#1085#1085#1099#1077
      Properties.NullStyle = nssUnchecked
      Properties.ValueChecked = 1
      Properties.ValueUnchecked = 0
      Properties.OnChange = cbIsOkPropertiesChange
      State = cbsGrayed
      TabOrder = 4
      Width = 170
    end
  end
  inherited dlgDS: TDataSource
    DataSet = qRR
  end
  object qRR: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    CachedUpdates = True
    SQL.Strings = (
      'SELECT RR.*, SD.SDNAME as type_request,'
      
        'p1.plastname || '#39' '#39' || SUBSTRING(p1.pname FROM 1 FOR 1) || '#39'. '#39' ' +
        '|| COALESCE(SUBSTRING(p1.ppatronymic FROM 1 FOR 1) || '#39'.'#39', '#39' '#39') ' +
        'AS autor,'
      
        'p2.plastname || '#39' '#39' || SUBSTRING(p2.pname FROM 1 FOR 1) || '#39'. '#39' ' +
        '|| COALESCE(SUBSTRING(p2.ppatronymic FROM 1 FOR 1) || '#39'.'#39', '#39' '#39') ' +
        'AS redaktor,'
      
        'p4.plastname || '#39' '#39' || SUBSTRING(p4.pname FROM 1 FOR 1) || '#39'. '#39' ' +
        '|| COALESCE(SUBSTRING(p4.ppatronymic FROM 1 FOR 1) || '#39'.'#39', '#39' '#39') ' +
        'AS fio_poluch,'
      
        'p5.plastname || '#39' '#39' || SUBSTRING(p5.pname FROM 1 FOR 1) || '#39'. '#39' ' +
        '|| COALESCE(SUBSTRING(p5.ppatronymic FROM 1 FOR 1) || '#39'.'#39', '#39' '#39') ' +
        'AS fio_dl,'
      'dp1.sdname AS podr, RDO.SCID, ST.STNAME'
      'FROM REGISTR_REQUEST RR'
      
        'LEFT OUTER JOIN REQUEST_OTKAZ RO ON RO.RID = RR.RID AND RR.RRTYP' +
        'E = 11912'
      'LEFT OUTER JOIN REQUEST_DEF_OTKAZ RDO ON RDO.RID = RO.RID'
      'LEFT OUTER JOIN SERVICES S ON S.SCID = RDO.SCID'
      'LEFT OUTER JOIN SERVICES_TYPE ST ON ST.STID = S.STID'
      'LEFT OUTER JOIN SYS_DIC SD ON SD.SDID = RR.RRTYPE'
      'LEFT OUTER JOIN USERS U1 ON U1.USNAME = RR.RRUSERENTER'
      'LEFT OUTER JOIN PEOPLE P1 ON P1.PID = U1.PID'
      'LEFT OUTER JOIN USERS U2 ON U2.USNAME = RR.RRUSEREDIT'
      'LEFT OUTER JOIN PEOPLE P2 ON P2.PID = U2.PID'
      'LEFT OUTER JOIN PEOPLE P4 ON P4.PID = RR.PID_POLUCH'
      'LEFT OUTER JOIN PEOPLE P5 ON P5.PID = RR.PID'
      'LEFT OUTER JOIN ( '
      'SELECT apu.PID, sd.SDNAME'
      'FROM DETI_PODRAZD_SC DP '
      'INNER JOIN SPEC_COND SC ON SC.SCID = DP.SCID '
      'INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = SC.AGID '
      'INNER JOIN SYS_DIC SD ON SD.SDID = DP.SDID '
      ' where DP.DPTYPE = 1 AND SC.SCISDELETE IS NULL '
      'and  CURRENT_DATE BETWEEN CAST(dp.DPDATEIN AS DATE) '
      '    AND COALESCE(CAST(dp.DPDATEOUT AS DATE), CURRENT_DATE) '
      ') as dp1 on dp1.pid = RR.PID_POLUCH')
    UpdateObject = quRR
    GeneratorField.Field = 'RRID'
    GeneratorField.Generator = 'GEN_REGISTR_REQUEST_ID'
    Left = 296
    object qRRRRID: TIntegerField
      FieldName = 'RRID'
      Origin = '"REGISTR_REQUEST"."RRID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object qRRRRTYPE: TIntegerField
      FieldName = 'RRTYPE'
      Origin = '"REGISTR_REQUEST"."RRTYPE"'
    end
    object qRRRID: TIntegerField
      FieldName = 'RID'
      Origin = '"REGISTR_REQUEST"."RID"'
    end
    object qRRRRUSERENTER: TIBStringField
      FieldName = 'RRUSERENTER'
      Origin = '"REGISTR_REQUEST"."RRUSERENTER"'
      Size = 40
    end
    object qRRRRTIMEENTER: TDateTimeField
      FieldName = 'RRTIMEENTER'
      Origin = '"REGISTR_REQUEST"."RRTIMEENTER"'
    end
    object qRRRRUSEREDIT: TIBStringField
      FieldName = 'RRUSEREDIT'
      Origin = '"REGISTR_REQUEST"."RRUSEREDIT"'
      Size = 40
    end
    object qRRRRTIMEEDIT: TDateTimeField
      FieldName = 'RRTIMEEDIT'
      Origin = '"REGISTR_REQUEST"."RRTIMEEDIT"'
    end
    object qRRPID_POLUCH: TIntegerField
      FieldName = 'PID_POLUCH'
      Origin = '"REGISTR_REQUEST"."PID_POLUCH"'
    end
    object qRRPID: TIntegerField
      FieldName = 'PID'
      Origin = '"REGISTR_REQUEST"."PID"'
    end
    object qRRRRNOTE: TIBStringField
      FieldName = 'RRNOTE'
      Origin = '"REGISTR_REQUEST"."RRNOTE"'
      Size = 255
    end
    object qRRRRISDELETE: TIntegerField
      FieldName = 'RRISDELETE'
      Origin = '"REGISTR_REQUEST"."RRISDELETE"'
    end
    object qRRAUTOR: TIBStringField
      FieldName = 'AUTOR'
      ProviderFlags = []
      Size = 769
    end
    object qRRREDAKTOR: TIBStringField
      FieldName = 'REDAKTOR'
      ProviderFlags = []
      Size = 769
    end
    object qRRFIO_POLUCH: TIBStringField
      FieldName = 'FIO_POLUCH'
      ProviderFlags = []
      Size = 769
    end
    object qRRFIO_DL: TIBStringField
      FieldName = 'FIO_DL'
      ProviderFlags = []
      Size = 769
    end
    object qRRTYPE_REQUEST: TIBStringField
      FieldName = 'TYPE_REQUEST'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object qRRRRMANAGERNOTE: TIBStringField
      FieldName = 'RRMANAGERNOTE'
      Origin = '"REGISTR_REQUEST"."RRMANAGERNOTE"'
      Size = 2048
    end
    object qRRRRMANAGER: TIBStringField
      FieldName = 'RRMANAGER'
      Origin = '"REGISTR_REQUEST"."RRMANAGER"'
      Size = 40
    end
    object qRRRRDIREKTORNOTE: TIBStringField
      FieldName = 'RRDIREKTORNOTE'
      Origin = '"REGISTR_REQUEST"."RRDIREKTORNOTE"'
      Size = 2048
    end
    object qRRRRDIREKTOROK: TIntegerField
      FieldName = 'RRDIREKTOROK'
      Origin = '"REGISTR_REQUEST"."RRDIREKTOROK"'
    end
    object qRRRRCLIENTANSWER: TIBStringField
      FieldName = 'RRCLIENTANSWER'
      Origin = '"REGISTR_REQUEST"."RRCLIENTANSWER"'
      Size = 2048
    end
    object qRRPODR: TIBStringField
      FieldName = 'PODR'
      ProviderFlags = []
      Size = 255
    end
    object qRRSCID: TIntegerField
      FieldName = 'SCID'
      Origin = '"REQUEST_DEF_OTKAZ"."SCID"'
    end
    object qRRSTNAME: TIBStringField
      FieldName = 'STNAME'
      Origin = '"SERVICES_TYPE"."STNAME"'
      Size = 255
    end
  end
  object quRR: TIBUpdateSQL
    RefreshSQL.Strings = (
      'Select '
      '  RRID,'
      '  RRTYPE,'
      '  RID,'
      '  RRUSERENTER,'
      '  RRTIMEENTER,'
      '  RRUSEREDIT,'
      '  RRTIMEEDIT,'
      '  PID_POLUCH,'
      '  PID,'
      '  RRNOTE,'
      '  RRMANAGERNOTE,'
      '  RRMANAGER,'
      '  RRDIREKTORNOTE,'
      '  RRDIREKTOROK,'
      '  RRCLIENTANSWER,'
      '  RRISDELETE,'
      '  TYPE_REQUEST,'
      '  AUTOR,'
      '  REDAKTOR,'
      '  FIO_POLUCH,'
      '  FIO_DL'
      'from REGISTR_REQUEST '
      'where'
      '  RRID = :RRID')
    ModifySQL.Strings = (
      'update REGISTR_REQUEST'
      'set'
      '  PID = :PID,'
      '  PID_POLUCH = :PID_POLUCH,'
      '  RID = :RID,'
      '  RRCLIENTANSWER = :RRCLIENTANSWER,'
      '  RRDIREKTORNOTE = :RRDIREKTORNOTE,'
      '  RRDIREKTOROK = :RRDIREKTOROK,'
      '  RRID = :RRID,'
      '  RRISDELETE = :RRISDELETE,'
      '  RRMANAGERNOTE = :RRMANAGERNOTE,'
      '  RRNOTE = :RRNOTE,'
      '  RRTYPE = :RRTYPE'
      'where'
      '  RRID = :OLD_RRID')
    InsertSQL.Strings = (
      'insert into REGISTR_REQUEST'
      
        '  (PID, PID_POLUCH, RID, RRCLIENTANSWER, RRDIREKTORNOTE, RRDIREK' +
        'TOROK, '
      '   RRID, RRISDELETE, RRMANAGERNOTE, RRNOTE, RRTYPE)'
      'values'
      
        '  (:PID, :PID_POLUCH, :RID, :RRCLIENTANSWER, :RRDIREKTORNOTE, :R' +
        'RDIREKTOROK, '
      '   :RRID, :RRISDELETE, :RRMANAGERNOTE, :RRNOTE, :RRTYPE)')
    DeleteSQL.Strings = (
      'update REGISTR_REQUEST'
      'set'
      '  RRISDELETE =1 '
      'where'
      '  RRID = :OLD_RRID')
    Left = 336
  end
  object dsSD: TDataSource
    DataSet = qSD
    Left = 595
    Top = 118
  end
  object qSD: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      
        'SELECT FIRST 1 '#39' '#1042#1089#1077#39' AS sdname, -1 AS sdid, 26 AS sdparid, NULL' +
        ' AS sdisdelete'
      'FROM SYS_DIC sd3'
      'UNION'
      'SELECT t1.*, SD1.SDISDELETE'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID  = 26'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39' '#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t '
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'INNER JOIN SYS_DIC sd1 ON sd1.SDID = t1.sdid'
      'order by 1'
      '')
    GeneratorField.Field = 'SDID'
    Left = 632
    Top = 120
    object qSDSDID: TIntegerField
      FieldName = 'SDID'
      ProviderFlags = []
    end
    object qSDSDPARID: TIntegerField
      FieldName = 'SDPARID'
      ProviderFlags = []
    end
    object qSDSDNAME: TIBStringField
      DisplayLabel = #1069#1083#1077#1084#1077#1085#1090
      FieldName = 'SDNAME'
      ProviderFlags = []
      Size = 2304
    end
    object qSDSDISDELETE: TIntegerField
      DisplayLabel = #1059#1076#1072#1083#1080#1090#1100'?'
      FieldName = 'SDISDELETE'
      Origin = '"SYS_DIC"."SDISDELETE"'
    end
  end
  object qTemp: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT RR.*, SD.SDNAME as type_request,'
      
        'p1.plastname || '#39' '#39' || SUBSTRING(p1.pname FROM 1 FOR 1) || '#39'. '#39' ' +
        '|| COALESCE(SUBSTRING(p1.ppatronymic FROM 1 FOR 1) || '#39'.'#39', '#39' '#39') ' +
        'AS autor,'
      
        'p2.plastname || '#39' '#39' || SUBSTRING(p2.pname FROM 1 FOR 1) || '#39'. '#39' ' +
        '|| COALESCE(SUBSTRING(p2.ppatronymic FROM 1 FOR 1) || '#39'.'#39', '#39' '#39') ' +
        'AS redaktor,'
      
        'p4.plastname || '#39' '#39' || SUBSTRING(p4.pname FROM 1 FOR 1) || '#39'. '#39' ' +
        '|| COALESCE(SUBSTRING(p4.ppatronymic FROM 1 FOR 1) || '#39'.'#39', '#39' '#39') ' +
        'AS fio_poluch,'
      
        'p5.plastname || '#39' '#39' || SUBSTRING(p5.pname FROM 1 FOR 1) || '#39'. '#39' ' +
        '|| COALESCE(SUBSTRING(p5.ppatronymic FROM 1 FOR 1) || '#39'.'#39', '#39' '#39') ' +
        'AS fio_dl,'
      'dp1.sdname AS podr, RDO.SCID, ST.STNAME'
      'FROM REGISTR_REQUEST RR'
      
        'LEFT OUTER JOIN REQUEST_OTKAZ RO ON RO.RID = RR.RID AND RR.RRTYP' +
        'E = 11912'
      'LEFT OUTER JOIN REQUEST_DEF_OTKAZ RDO ON RDO.RID = RO.RID'
      'LEFT OUTER JOIN SERVICES S ON S.SCID = RDO.SCID'
      'LEFT OUTER JOIN SERVICES_TYPE ST ON ST.STID = S.STID'
      'LEFT OUTER JOIN SYS_DIC SD ON SD.SDID = RR.RRTYPE'
      'LEFT OUTER JOIN USERS U1 ON U1.USNAME = RR.RRUSERENTER'
      'LEFT OUTER JOIN PEOPLE P1 ON P1.PID = U1.PID'
      'LEFT OUTER JOIN USERS U2 ON U2.USNAME = RR.RRUSEREDIT'
      'LEFT OUTER JOIN PEOPLE P2 ON P2.PID = U2.PID'
      'LEFT OUTER JOIN PEOPLE P4 ON P4.PID = RR.PID_POLUCH'
      'LEFT OUTER JOIN PEOPLE P5 ON P5.PID = RR.PID'
      'LEFT OUTER JOIN ( '
      'SELECT apu.PID, sd.SDNAME'
      'FROM DETI_PODRAZD_SC DP '
      'INNER JOIN SPEC_COND SC ON SC.SCID = DP.SCID '
      'INNER JOIN AGR_POLUCH_USLUG APU ON APU.AGID = SC.AGID '
      'INNER JOIN SYS_DIC SD ON SD.SDID = DP.SDID '
      ' where DP.DPTYPE = 1 AND SC.SCISDELETE IS NULL '
      'and  CURRENT_DATE BETWEEN CAST(dp.DPDATEIN AS DATE) '
      '    AND COALESCE(CAST(dp.DPDATEOUT AS DATE), CURRENT_DATE) '
      ') as dp1 on dp1.pid = RR.PID_POLUCH')
    GeneratorField.Field = 'RRID'
    Left = 296
    Top = 32
    object IntegerField1: TIntegerField
      FieldName = 'RRID'
      Origin = '"REGISTR_REQUEST"."RRID"'
      ProviderFlags = [pfInUpdate, pfInWhere, pfInKey]
      Required = True
    end
    object IntegerField2: TIntegerField
      FieldName = 'RRTYPE'
      Origin = '"REGISTR_REQUEST"."RRTYPE"'
    end
    object IntegerField3: TIntegerField
      FieldName = 'RID'
      Origin = '"REGISTR_REQUEST"."RID"'
    end
    object IBStringField1: TIBStringField
      FieldName = 'RRUSERENTER'
      Origin = '"REGISTR_REQUEST"."RRUSERENTER"'
      Size = 40
    end
    object DateTimeField1: TDateTimeField
      FieldName = 'RRTIMEENTER'
      Origin = '"REGISTR_REQUEST"."RRTIMEENTER"'
    end
    object IBStringField2: TIBStringField
      FieldName = 'RRUSEREDIT'
      Origin = '"REGISTR_REQUEST"."RRUSEREDIT"'
      Size = 40
    end
    object DateTimeField2: TDateTimeField
      FieldName = 'RRTIMEEDIT'
      Origin = '"REGISTR_REQUEST"."RRTIMEEDIT"'
    end
    object IntegerField4: TIntegerField
      FieldName = 'PID_POLUCH'
      Origin = '"REGISTR_REQUEST"."PID_POLUCH"'
    end
    object IntegerField5: TIntegerField
      FieldName = 'PID'
      Origin = '"REGISTR_REQUEST"."PID"'
    end
    object IBStringField3: TIBStringField
      FieldName = 'RRNOTE'
      Origin = '"REGISTR_REQUEST"."RRNOTE"'
      Size = 255
    end
    object IntegerField6: TIntegerField
      FieldName = 'RRISDELETE'
      Origin = '"REGISTR_REQUEST"."RRISDELETE"'
    end
    object IBStringField4: TIBStringField
      FieldName = 'AUTOR'
      ProviderFlags = []
      Size = 769
    end
    object IBStringField5: TIBStringField
      FieldName = 'REDAKTOR'
      ProviderFlags = []
      Size = 769
    end
    object IBStringField6: TIBStringField
      FieldName = 'FIO_POLUCH'
      ProviderFlags = []
      Size = 769
    end
    object IBStringField7: TIBStringField
      FieldName = 'FIO_DL'
      ProviderFlags = []
      Size = 769
    end
    object IBStringField8: TIBStringField
      FieldName = 'TYPE_REQUEST'
      Origin = '"SYS_DIC"."SDNAME"'
      Size = 255
    end
    object IntegerField7: TIntegerField
      FieldName = 'IS_FORMALIZ'
      ProviderFlags = []
    end
  end
  object qUserFilter: TIBQuery
    Database = DMInv.DBRead
    Transaction = DMInv.IBTransaction1
    SQL.Strings = (
      'SELECT LIST(t1.sdid, '#39', '#39') AS list_sdid'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID in (1412, 1413)'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t'
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t1'
      'INNER JOIN SYS_DIC sd1 ON sd1.SDID = t1.sdid'
      'WHERE NOT EXISTS'
      '('
      'SELECT t2.sdid'
      'FROM'
      '('
      'WITH   recursive'
      '   tree (SDNAME, SDID, SDPARID, o)'
      
        '   AS (SELECT SD.SDNAME, SD.SDID, sd.SDPARID, CAST('#39#39' AS VARCHAR' +
        '(2048)) AS o FROM SYS_DIC SD'
      '      WHERE sd.SDPARID in (1412, 1413)'
      '      UNION ALL'
      '      SELECT SD1.SDNAME, SD1.SDID, sd1.SDPARID, '#39#39' || o'
      ''
      '      FROM SYS_DIC SD1'
      '          INNER JOIN tree t'
      '           ON t.sdid = sd1.SDPARID)'
      ' SELECT  o || SDNAME AS SDNAME, SDID, SDPARID FROM tree t'
      ') AS t2'
      'INNER JOIN SYS_DIC sd1 ON sd1.SDID = t1.sdid'
      'WHERE t2.sdparid = t1.sdid'
      ')')
    Left = 336
    Top = 32
    object qUserFilterLIST_SDID: TMemoField
      FieldName = 'LIST_SDID'
      ProviderFlags = []
      BlobType = ftMemo
      Size = 8
    end
  end
end
